package com.example.jc

import android.app.Application
import coil.ImageLoader
import coil.ImageLoaderFactory
import coil.disk.DiskCache
import coil.memory.MemoryCache

/**
 * XiaoYao,万家灯火 华灯初上
 * @Description:
 * @Author: 肖垚 1094890313@qq.com
 * @create: 2022年04月26日 16:40
 * @Version 1.0
 **/
class MyApplication : Application(), ImageLoaderFactory {
    override fun newImageLoader(): ImageLoader {
//        TODO("Not yet implemented")
//        return ImageLoader.Builder(getApplicationContext())
        return ImageLoader.Builder( applicationContext)
            .crossfade(true)
            .memoryCache {
                MemoryCache.Builder(this)
                    .maxSizePercent(0.10)
//                    .maxSizeBytes(1024*1024 *30)
                    .build()
            }
            .diskCache {
                DiskCache.Builder()
                    .directory(this.cacheDir.resolve("image_cache"))
//                    .directory(this.safeCacheDir.resolve("image_cache"))
                    .maxSizePercent(0.01)
//                    .maxSizeBytes(1024*1024 *30)
                    .build()
            }
            .build()
    }

}